close(dmi_res->guest_tx_fh); dmi_res->guest_tx_fh = -1;
close(dmi_res->vtpm_tx_fh); dmi_res->vtpm_tx_fh = -1;
-
+ vtpm_globals->connected_dmis--;
+
+ if (vtpm_globals->connected_dmis == 0) {
+ // No more DMI's connected. Close fifo to prevent a broken pipe.
+ close(vtpm_globals->guest_rx_fh);
+ vtpm_globals->guest_rx_fh = -1;
+ }
#ifndef MANUAL_DM_LAUNCH
if (dmi_res->dmi_id != VTPM_CTL_DM) {
if (dmi_res->dmi_pid != 0) {
status = TPM_BAD_PARAMETER;
goto abort_egress;
} else {
+ vtpm_globals->connected_dmis++; // Put this here so we don't count Dom0
BSG_UnpackList( param_buf->bytes, 3,
BSG_TYPE_BYTE, &type,
BSG_TYPE_UINT32, &domain_id,
TPM_RESULT status=TPM_SUCCESS;
int fh, dmis=-1;
- BYTE *flat_boot_key, *flat_dmis, *flat_enc;
- buffer_t clear_flat_global, enc_flat_global;
+ BYTE *flat_boot_key=NULL, *flat_dmis=NULL, *flat_enc=NULL;
+ buffer_t clear_flat_global=NULL_BUF, enc_flat_global=NULL_BUF;
UINT32 storageKeySize = buffer_len(&vtpm_globals->storageKeyWrap);
UINT32 bootKeySize = buffer_len(&vtpm_globals->bootKeyWrap);
struct pack_buf_t storage_key_pack = {storageKeySize, vtpm_globals->storageKeyWrap.bytes};
sizeof(UINT32) +// storagekeysize
storageKeySize, NULL) ); // storage key
- flat_dmis_size = (hashtable_count(vtpm_globals->dmi_map) - 1) * // num DMIS (-1 for Dom0)
- (sizeof(UINT32) + 2*sizeof(TPM_DIGEST)); // Per DMI info
flat_boot_key = (BYTE *) malloc( boot_key_size );
flat_enc = (BYTE *) malloc( sizeof(UINT32) );
- flat_dmis = (BYTE *) malloc( flat_dmis_size );
boot_key_size = BSG_PackList(flat_boot_key, 1,
BSG_TPM_SIZE32_DATA, &boot_key_pack);
BSG_PackConst(buffer_len(&enc_flat_global), 4, flat_enc);
- // Per DMI values to be saved
+ // Per DMI values to be saved (if any exit)
if (hashtable_count(vtpm_globals->dmi_map) > 0) {
+ flat_dmis_size = (hashtable_count(vtpm_globals->dmi_map) - 1) * // num DMIS (-1 for Dom0)
+ (sizeof(UINT32) + 2*sizeof(TPM_DIGEST)); // Per DMI info
+ flat_dmis = (BYTE *) malloc( flat_dmis_size );
+
dmi_itr = hashtable_iterator(vtpm_globals->dmi_map);
do {
dmi_res = (VTPM_DMI_RESOURCE *) hashtable_iterator_value(dmi_itr);